<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>
        <div class="container">
            <div class="row clearfix">
                <div class="col-md-12 column">
                    <h1 class="text-center">
                        记流水账
                    </h1>
                    <h3 class="text-right text-success">
                        欢迎您:XXX
                        <#--<@shiro.principal property="name" />-->
                    </h3>

                        <div class="container">
                            <div class="row clearfix">
                                <div class="col-md-12 column">
                                    <div class="row clearfix">
                                        <div class="col-md-2 column">
                                        </div>
        <div class="col-md-6 column">
            <form class="form-horizontal" role="form" id="form">
                <div class="form-group">
                    <label for="itemId" class="col-sm-2 control-label">记账事项</label>
                    <div class="col-sm-10">
                        <select name="itemId" class="form-control" id="accountItem">
                            <option value="0">请选择菜单</option>
                            <#if itemList?exists>
                                <#list itemList as item>
                                    <option value="${item.id?if_exists}" >${item.content}</option>
                                    <#--<option value="${model.id?if_exists}" <#if menu.parentId== model.id>selected</#if>>${model.name}</option>-->
                                </#list>
                            </#if>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="operationDate" class="col-sm-2 control-label">业务日期</label>
                    <div class="col-sm-10">
                        <input type="date" class="form-control" id="operationDate"
                        name="operationDate"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="contact" class="col-sm-2 control-label">关系人</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="contact"
                               name="contact"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="company" class="col-sm-2 control-label">往来单位</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="company"
                               name="company"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="reason" class="col-sm-2 control-label">事由</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="reason"
                               name="reason"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="accountState" class="col-sm-2 control-label">进/出账</label>
                    <div class="col-sm-10">
                        <select name="accountState" class="form-control" id="accountState">
                            <option value="-1">请选择菜单</option>
                            <option value="1" >进账</option>
                            <option value="0" >出账</option>

                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="money" class="col-sm-2 control-label">金额(元)</label>
                    <div class="col-sm-10">
                        <input type="money" class="form-control" id="money" name="money"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="car" class="col-sm-2 control-label">相关车辆</label>
                    <div class="col-sm-10">
                        <input type="car" class="form-control" id="car" name="car"/>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-success"
                        onclick="accountSubmit()">提交</button>
                        <button type="button" class="btn btn-info"
                                onclick="history.back()">返回</button>
                    </div>
                </div>
            </form>
        </div>
            <div class="col-md-4 column">
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-success"
                        onclick="location.href='/item/add-ui'">添加</button>
                    </div>
                </div>
            </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <script src="/static/js/jquery-1.8.0.min.js" ></script>
        <script>
            // 添加账目信息
            function accountSubmit(){
                //1. 获取form表单中的全部内容
                var data = $("#form").serialize(); // 将携带name属性的表单项拼接为key=value&key=value..
                //2. 发送ajax请求到后台,并传递全部的参数.
                $.post(
                    "/account/add",
                    data,
                    function(result){

                        if(result.code == 0){
                            alert(result.msg)
                            location.href = "/account/list";
                        }
                    },
                    "json"
                );
            }
        </script>
    </body>
</html>